const path = require('path');
const nodeExternals = require('webpack-node-externals')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
module.exports = {
    entry: './src/index.js',
    output: {
        path: path.join(__dirname,'../dist'),
        filename: '[name].js'
    },
    plugins:[
        new CleanWebpackPlugin(), // 打包前清除输出目录
    ],
    target: 'node',
    optimization: {
        minimizer: [
            (compiler) => {
                const TerserPlugin = require('terser-webpack-plugin');
                new TerserPlugin({
                    terserOptions: {
                        compress: {},
                    }
                }).apply(compiler);
            },
        ]
    },
    node: {
        global: true,
        __filename: true,
        __dirname: true,
    }
}
